/** <a href="http://www.cpupk.com/decompiler">Eclipse Class Decompiler</a> plugin, Copyright (c) 2017 Chen Chao. **/
package com.minierp.validator;

import com.minierp.model.Storehouse;
import org.springframework.validation.Errors;
import org.springframework.validation.Validator;

public class StorehouseValidator implements Validator {
	public boolean supports(Class clazz) {
		return Storehouse.class.isAssignableFrom(clazz);
	}

	public void validate(Object obj, Errors errors) {
		Storehouse form = (Storehouse) obj;
		if (form.getStoName() != null && !form.getStoName().trim().equals("")) {
			if (form.getTallySetId() == 0L) {
				errors.rejectValue("tallySetId", "", "请选择『帐套』");
			}
		} else {
			errors.rejectValue("stoName", "", "请输入『名称』");
		}

	}
}